import java.util.Arrays;

public class Practice4 {
    //调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序。
    //
    //如数组：[1,2,3,4,5,6]
    //
    //调整后可能是：[1, 5, 3, 4, 2, 6]
    public static void main(String[] args) {
        int[] arr = {1,5,3,9,8,6,3,4,7,8,5,3,5};
        reverse(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void reverse(int[] arr){
        int left = 0;
        int right = arr.length - 1;
        while (left < right){

            while (left < right && (arr[left] % 2) != 0){
                left++;
            }
            while (left < right && (arr[right] % 2) == 0){
                right--;
            }
            int temp = arr[left];
            arr[left] = arr[right];
            arr[right] = temp;

        }
    }
}
